/*
 * Copyright (c) 2025 CAX Conversion Project
 */
package com.comac.ins.isfd.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.comac.ins.common.core.domain.R;
import com.comac.ins.common.web.core.BaseController;
import com.comac.ins.isfd.domain.vo.IsfdMetadataBusinessSceneDefinitionVo;
import com.comac.ins.isfd.domain.vo.blood.BloodRelationshipVo;
import com.comac.ins.isfd.service.IIsfdMetadataManagementAnalysisService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 元数据管理分析
 *
 * @author hxloongs
 * @date 2024-09-23
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/isfd/metadataManagementAnalysis")
public class IsfdMetadataManagementAnalysisController extends BaseController {

    @Autowired
    private IIsfdMetadataManagementAnalysisService iIsfdMetadataManagementAnalysisService;

    /**
     * 元数据分析详情接口
     */
    @SaCheckPermission("isfd:metadataManagementAnalysis:detail")
    @GetMapping("/detail")
    public R<IsfdMetadataBusinessSceneDefinitionVo> getInfo(@RequestParam("businessId") Long businessId) {
        return R.ok(iIsfdMetadataManagementAnalysisService.getInfo(businessId));
    }


    /**
     * 根据要素数据库id查询要数据管理id列表
     */
    @SaCheckPermission("isfd:metadataManagementAnalysis:queryManagementIds")
    @GetMapping("/queryManagementIds")
    public R<List<String>> queryManagementIds(@RequestParam("businessId") Long businessId,
                                              @RequestParam("databaseId") Long databaseId) {
        return R.ok(iIsfdMetadataManagementAnalysisService.queryManagementIds(businessId,databaseId));
    }


    /**
     * 元数据分析数据血缘关系
     */
    @SaCheckPermission("isfd:metadataManagementAnalysis:blood:relationship")
    @GetMapping("/blood/relationship")
    public R<BloodRelationshipVo> bloodRelationship(@RequestParam("businessId") Long businessId,
                                                    @RequestParam("databaseId") Long databaseId) {
        return R.ok(iIsfdMetadataManagementAnalysisService.bloodRelationship(businessId, databaseId));
    }
}
